<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="">
			<img id="img_id" src='../../img/1.jpg'>
		</div>
		<button type="button" onclick="begin();">开始</button>
		
	</body>
	<script type="text/javascript">
			
		function begin(){
			//定义一个数组装图片
			var arr=["../../img/1.jpg","../../img/2.jpg","../../img/3.jpg","../../img/4.jpg","../../img/5.jpg","../../img/6.jpg","../../img/7.jpg","../../img/8.jpg","../../img/9.jpg"];
			//
			var index = 0;
			setInterval(function(){	
				if(index == arr.length){
					index = 0;
				}
			document.getElementById("img_id").setAttribute("src",arr[index]);
			console.log(index)
			index++;
		},300)
		}
	</script>
</html>
